<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>打印金字塔</title>
    <style>
        *{
            font-family: cursive;
        }
    </style>
</head>
<body>
    <script>


        var num = prompt("请输入金字塔层数");

        for(var i = 0;i < num ;i++) {
            for (var k = 0; k < num - i - 1; k++) {
                document.writeln("&nbsp;");
            }
            for (var j = 0; j <= (2 * i -1) + 1; j++) {
                document.writeln("*");
            }
            document.writeln("<br/>");
        }


        /*var num = 90;
        for (i = 0; i <= num; i++){
            for ( j = 0; j < num - i; j++){
                document.write("&nbsp");
            }
            for ( p = 0; p < (2* i-1 )+1; p++){
                document.write("*");
            }
            document.write("<br>");
        }*/




    </script>
</body>
</html>